//结构体
#include <stdio.h>
	typedef struct people{
		char name[20];
		int year;
		int month;
	}pl;//定义一个关于学生信息的结构体，包括姓名，出生年月
void bubblesort(pl *student,int number);//函数用小写
int main()
{
	int n=0; int i = 0;
	printf("please enter the number of student:  ");//提示用户输入人数
	scanf("%d",&n);
	pl student[n];//定义一个学生信息
	int k=0;
	printf("please enter the information of student(  name  year  momth）:\n");
	for(k=0;k<n;k++)
	{
		scanf("%s %d %d",student[k].name,&student[k].year,&student[k].month);
	}
	bubblesort(student,n);//冒泡排序
	printf("\nSorted Student Information:\n");//输出排序后的学生信息
    for (int i = 0; i < n; i++) {
        printf("Name: %s, Year: %d, Month: %d\n", student[i].name, student[i].year, student[i].month);
    }
    return 0;
}
//	Marry 2002 10
//	Mike 2005 9
//	Lisa 2001 8
//	Max 2002 6
//	Linda 2008 4
//	Cindy 2002 5
//	zip 2004 1
//	zoom 2003 10
//	Jhon 2004 12

void bubblesort(pl *student,int number)
{
	int i=0,j=0;
		for(i=0;i<number-1;i++)
	{
		for(j=0;j<number-i-1;j++)
		{
			if(student[j].year>student[j+1].year)
			{
				pl temp=student[j];
				student[j]=student[j+1];
				student[j+1]=temp;
			}
					if(student[i].year==student[i+1].year&&student[i].month>student[i+1].month)
			{//年龄相同，则排月份
				pl temp=student[i];
				student[i]=student[i+1];
				student[i+1]=temp;
			}
			
		}

	}
}